package com.example.spring_boot_demo.controller;

import com.example.spring_boot_demo.dto.GoodsRequest;
import com.example.spring_boot_demo.service.GoodsService;
import com.example.spring_boot_demo.utils.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <P> @Author: SongKeCheng
 * <P> Type: Class
 * <P> Description: 查询书籍信息
 * <P> Date: 2024/5/29:19:44
 */

@SuppressWarnings({"unchecked", ""})
@RestController
@RequestMapping("goods")
public class GoodsController {
    private static final Logger log = LoggerFactory.getLogger(GoodsController.class);


    @Autowired
    private GoodsService goodsService;

    /**
     * 根据条件查询书籍信息 并且进行分页
    */
    @PostMapping("/findGoods")
    public AjaxResult findGoods(GoodsRequest goodsRequest){
        return goodsService.findGoods(goodsRequest);
    }
    /**
     * 根据id 删除商品信息
     */
    @PostMapping("/deleteGoods")
    public AjaxResult deleteGoods(GoodsRequest goodsRequest){
        return goodsService.deleteGoods(goodsRequest);
    }
    /**
     * 根据id 更新商品信息
     */
    @PostMapping("/updateGoods")
    public AjaxResult updateGoods(@RequestBody GoodsRequest goodsRequest){
        return goodsService.updateGoods(goodsRequest);
    }

    /**
     * 新增书籍信息
    */

    @PostMapping("/addGoods")
    public AjaxResult addGoods(@RequestBody GoodsRequest goodsRequest){
        return goodsService.addGoods(goodsRequest);
    }
}
